package com.example.onlineeducation.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.onlineeducation.base.BaseViewModel
import com.example.onlineeducation.data.entity.ExamEntity
import com.example.onlineeducation.repository.MainTopicRepository
import com.yc.jetpacklib.net.YcResult
import kotlinx.coroutines.flow.collectLatest

class UnpassExamListVM : BaseViewModel() {
    private val mMainTopicRepository: MainTopicRepository by lazy { MainTopicRepository(mApiService) }

    private val _mExamListDataModel = MutableLiveData<YcResult<List<ExamEntity>?>>()
    val mExamListDataModel: LiveData<YcResult<List<ExamEntity>?>> = _mExamListDataModel
    fun getExamList(projectId: String, groupId: String) = ycLaunch {
        mMainTopicRepository.getExamList(projectId, groupId).collectLatest {
            _mExamListDataModel.postValue(it)
        }
    }
    private val _mCheckStudyTimeDataModel = MutableLiveData<YcResult<String?>>()
    val mCheckStudyTimeDataModel: LiveData<YcResult<String?>> = _mCheckStudyTimeDataModel
    fun getCheckStudyTime(projectId: String, topicId: String) = ycLaunch {
        mMainTopicRepository.getCheckStudyTime(projectId, topicId).collectLatest {
            _mCheckStudyTimeDataModel.postValue(it)
        }
    }

}
